package xyz.xtt.asset.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.hutool.json.JSONUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import xyz.xtt.asset.client.request.ReMintRequest;
import xyz.xtt.asset.client.response.MintResponse;
import xyz.xtt.asset.constants.ErrorMessage;
import xyz.xtt.asset.enums.OrderTypeEnum;
import xyz.xtt.asset.service.ITblRemintAccountService;
import xyz.xtt.common.asset.AssertUtils;
import xyz.xtt.common.response.ApiResult;

@Tag(name = "资产管理", description = "订单管理")
@RefreshScope
@Slf4j
@RequestMapping("/api/third/asset")
@RestController
public class InnerNftOrderController {
	@Autowired
	private ITblRemintAccountService iTblRemintAccountService;

	@Operation(summary = "铸造权")
	@PostMapping("/reMint")
	public ApiResult<MintResponse> reMint(@RequestHeader("uid") String uid, @RequestBody @Valid ReMintRequest mintRequest) {
		log.info("/api/asset/nft/reMint param:{}", JSONUtil.toJsonStr(mintRequest));
		MintResponse mint = iTblRemintAccountService.reMint(uid, mintRequest, OrderTypeEnum.C_TO_C);
		AssertUtils.isNull(mint, ErrorMessage.UNKNOWN_ERROR);
		return ApiResult.ok(mint);
	}

}
